#include <iostream>

using namespace std;

#define N 100005

struct stack{
    int top = 0;
    char a[N];

    void push(char e){
        a[++top] = e;
    }

    void pop(){
        top--;
    }

    char get_top(){
        return a[top];
    }

    bool empty(){
        if (top == 0){
            return true;
        }
        return false;
    }
}s;

int main(){
    while(true){
        char ch = cin.get();
        if (ch == ' ' || ch == '\n' || ch == EOF){
            while (!s.empty()){
                cout << s.get_top();
                s.pop();
            }

            if (ch == '\n' || ch == EOF){
                break;
            }
            
            cout << " ";
        }
        else{
            s.push(ch);
        }
    }
    return 0;
}